﻿<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:Formatters="clr-namespace:MySemanticSearch.Formatters" x:Class="MySemanticSearch.MainPage"
    mc:Ignorable="d"
    Width="1210" Height="553">
    <UserControl.Resources>
        <Formatters:ScoreFormatter x:Key="ScoreFormatter"></Formatters:ScoreFormatter>
    </UserControl.Resources>
    <Grid Name="MainGrid" Width="1210" Height="555" HorizontalAlignment="Left" VerticalAlignment="Top" Background="White">
        <Grid Margin="791,0,0,0" Width="419" Height="549" HorizontalAlignment="Left" VerticalAlignment="Top">
            <Rectangle HorizontalAlignment="Left" Width="412" Height="520" Margin="0,29,0,0" Style="{StaticResource ResourceKey=BackgroundRectangle}" Fill="{StaticResource ResourceKey=RectangleLinearGradientBrush}" />
            <sdk:Label Height="17" Margin="8,8,0,0" Content="Tag Cloud" Width="63" Style="{StaticResource ResourceKey=TitleLabel}" IsTabStop="False" />
            <sdk:Label Height="17" Margin="158,29,0,0" Content="Top Results" Style="{StaticResource ResourceKey=TitleLabel}" IsTabStop="False" />
            <Slider
                Height="18"
                Margin="127,44,133,0"
                VerticalAlignment="Top"
                Minimum="0"
                Maximum="{Binding SliderMaxValue}"
                Value="{Binding TopResultsSliderValue, Mode=TwoWay}" IsEnabled="{Binding IsFiletablesDropDownEnabled}" IsTabStop="True" TabIndex="19" />
            <sdk:TabControl HorizontalAlignment="Left" Margin="5,114,0,10" Width="402" IsTabStop="False">
                <sdk:TabItem Header="Tag Cloud" GotFocus="SetupCloudRotation" IsTabStop="True" TabIndex="20">
                    <Grid Margin="0,0,0,0" VerticalAlignment="Top">
                        <Rectangle Margin="0,0,0,0" Height="422" Width="362" Style="{StaticResource ResourceKey=CanvasRectangle}"  />
                        <Canvas x:Name="CanvasTagCloud" Height="388" Width="387" VerticalAlignment="Top">
                        	<Canvas.Background>
                                <LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0">
                                    <GradientStop Color="#FFB1C3FB"/>
                                    <GradientStop Color="#FFDFE7F5" Offset="0.121"/>
                                    <GradientStop Color="White" Offset="0.681"/>
                                </LinearGradientBrush>
                            </Canvas.Background>
                        </Canvas>
                        <Image Source="Images/denali_logo.png" Width="165" RenderTransformOrigin="0.625,1.294" Style="{StaticResource ResourceKey=ImageStyle}" Height="46.8" VerticalAlignment="Bottom" HorizontalAlignment="Right" Margin="0,0,0,1" />						
                    </Grid>                    
                </sdk:TabItem>
                <sdk:TabItem Header="Tag Grid" IsTabStop="True" TabIndex="21">
                    <Grid>
                        <sdk:DataGrid SelectedItem="{Binding TagGridSelectedItem, Mode=TwoWay}" Margin="0,0,0,0" Height="385" Width="360" Grid.Column="0" Grid.Row="2" ItemsSource="{Binding TagCloudTags}" SelectionMode="Single" AutoGenerateColumns="False" Style="{StaticResource MainDataGridStyle}" TabIndex="22">
                            <sdk:DataGrid.Columns>
                                <sdk:DataGridTextColumn Binding="{Binding Name}" Width="220" CanUserReorder="False" CanUserResize="True" CanUserSort="False" Header="Tag" IsReadOnly="True" SortMemberPath="Score"/>
                                <sdk:DataGridTextColumn Binding="{Binding Score}" Width="105" CanUserReorder="False" CanUserResize="True" CanUserSort="False" Header="Score" IsReadOnly="True"/>
                            </sdk:DataGrid.Columns>
                        </sdk:DataGrid>
                    </Grid>
                </sdk:TabItem>    
            </sdk:TabControl>            
        </Grid>
        <Grid Margin="256,0,0,0" HorizontalAlignment="Left" Width="529" Height="549" VerticalAlignment="Top">
            <Rectangle Margin="0,29,0,0" Height="520" Fill="{StaticResource ResourceKey=RectangleLinearGradientBrush}" Style="{StaticResource ResourceKey=BackgroundRectangle}" />
            <sdk:Label Height="17" Width="72" Margin="8,8,0,0" Content="Documents" Style="{StaticResource ResourceKey=TitleLabel}" IsTabStop="False" />
            <Grid HorizontalAlignment="Left" Height="27" Margin="8,46,0,0" VerticalAlignment="Top" Width="84">
                <Button Content="Add" Command="{Binding AddDocumentCommand}" Style="{StaticResource MainButtonStyle}" IsEnabled="{Binding IsFiletablesDropDownEnabled}" TabIndex="11" TabNavigation="Once" IsTabStop="True" />
                <Image Source="Images/add.png" Width="17" Margin="8,6,0,7" Style="{StaticResource ResourceKey=ImageStyle}"/>
            </Grid>
            <Grid HorizontalAlignment="Left" Height="27" Margin="98,46,0,0" VerticalAlignment="Top" Width="84">
                <Button Content="Delete" Command="{Binding DeleteDocumentCommand}" Style="{StaticResource MainButtonStyle}" IsEnabled="{Binding IsDocumentSelected}" TabIndex="12" TabNavigation="Once" />
                <Image Source="Images/delete.png" Width="16" Margin="4,5,0,7" Style="{StaticResource ResourceKey=ImageStyle}"/>
            </Grid>
            <Grid Margin="8,82,8,8">
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="0"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition MinWidth="417"/>
                </Grid.ColumnDefinitions>
                <sdk:DataGrid x:Name="DocumentsDataGrid" IsEnabled="{Binding IsFiletablesDropDownEnabled}" ItemsSource="{Binding Documents}" AutoGenerateColumns="False" SelectionMode="Extended" Style="{StaticResource MainDataGridStyle}" TabIndex="15" Grid.RowSpan="2" Margin="0,0,0,16">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="SelectionChanged">
                            <i:InvokeCommandAction Command="{Binding DocumentSelectionChanged, Mode=TwoWay}" CommandParameter="{Binding SelectedItems, ElementName=DocumentsDataGrid, Mode=TwoWay}"/>
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                    <sdk:DataGrid.Columns>
                        <sdk:DataGridTemplateColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Header="Filetype" IsReadOnly="True" Width="64" SortMemberPath="FileType">
                            <sdk:DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Image Source="{Binding FileType, StringFormat=images/\{0\}.png}" Style="{StaticResource ResourceKey=DocumentIconStyle}"/>
                                </DataTemplate>
                            </sdk:DataGridTemplateColumn.CellTemplate>
                        </sdk:DataGridTemplateColumn>
                        <sdk:DataGridTextColumn Binding="{Binding FileName}" CanUserReorder="True" Width="338" CanUserResize="True" CanUserSort="True" Header="Filename" IsReadOnly="True" SortMemberPath="FileName" />
                        <sdk:DataGridTextColumn Binding="{Binding Score, Converter={StaticResource ScoreFormatter}}" CanUserReorder="True" CanUserResize="True" CanUserSort="True" Header="Tag frequency" IsReadOnly="True" SortMemberPath="Score" Width="110"></sdk:DataGridTextColumn>
                    </sdk:DataGrid.Columns>
                </sdk:DataGrid>
                <sdk:Label HorizontalContentAlignment="Center" Content="Related Documents" Grid.Row="1" Height="20" VerticalAlignment="Bottom" FontWeight="Bold" FontSize="12" IsTabStop="False" Margin="0,0,0,9" Grid.RowSpan="2" />
                <sdk:GridSplitter Grid.Column="0" Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Stretch" Height="10" TabIndex="16" TabNavigation="Once" IsTabStop="True" />
                <sdk:DataGrid x:Name="RelatedDocumentGrid" SelectedItem="{Binding SelectedRelatedDocument, Mode=TwoWay}" Grid.Column="0" Grid.Row="3" ItemsSource="{Binding RelatedDocuments}" IsEnabled="{Binding IsFiletablesDropDownEnabled}" AutoGenerateColumns="False" Style="{StaticResource MainDataGridStyle}" IsTabStop="True" TabIndex="17">
                    <sdk:DataGrid.Columns>
                        <sdk:DataGridTemplateColumn Width="64" CanUserReorder="True" CanUserResize="True" CanUserSort="True" Header="Filetype" IsReadOnly="True" >
                            <sdk:DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Image x:Name="_fileType" Source="{Binding FileType, StringFormat=images/\{0\}.png}" Style="{StaticResource ResourceKey=DocumentIconStyle}"/>
                                </DataTemplate>
                            </sdk:DataGridTemplateColumn.CellTemplate>
                        </sdk:DataGridTemplateColumn>
                        <sdk:DataGridTextColumn Binding="{Binding FileName}" Width="325" CanUserReorder="False" CanUserResize="True" CanUserSort="True" Header="Filename" IsReadOnly="True"/>
                        <sdk:DataGridTextColumn Binding="{Binding Score}" Width="125" CanUserReorder="False" CanUserResize="True" CanUserSort="True" Header="Correlation score" IsReadOnly="True"/>
                    </sdk:DataGrid.Columns>
                </sdk:DataGrid>
                <Button Style="{StaticResource MainButtonStyle}" Content="Find in upper list" Height="25" Grid.Row="4" Visibility="{Binding IsFindButtonVisible, Mode=TwoWay}" Command="{Binding UpdateDocumentListCommand}" IsTabStop="True" TabIndex="18" />
            </Grid>
            <Grid Height="27" Margin="188,46,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="93">
                <Button HorizontalContentAlignment="Right" Content="Download" Command="{Binding DownloadDocumentCommand}" Style="{StaticResource MainButtonStyle}" IsEnabled="{Binding IsDocumentSelected}" TabIndex="13" TabNavigation="Once" IsTabStop="True" />
                <Image Source="Images/download.png" Margin="6,7,0,6" Width="17" Style="{StaticResource ResourceKey=ImageStyle}"/>
            </Grid>
            <Grid HorizontalAlignment="Left" Height="27" Margin="394,47,0,0" VerticalAlignment="Top" Width="127">
                <Button HorizontalContentAlignment="Right" Content="File Information" Command="{Binding FileInformationCommand}" Style="{StaticResource MainButtonStyle}" IsEnabled="{Binding IsDocumentSelected}" TabIndex="14" TabNavigation="Once" IsTabStop="True" />
                <Image Source="Images/add.png" Width="17" Margin="1,6,0,7" Style="{StaticResource ResourceKey=ImageStyle}"/>
            </Grid>
        </Grid>
        <Grid HorizontalAlignment="Left" Margin="5,0,0,0" Width="245" Height="549" VerticalAlignment="Top">
            <Rectangle Margin="0,29,0,0" Height="520" Style="{StaticResource ResourceKey=BackgroundRectangle}" Fill="{StaticResource ResourceKey=RectangleLinearGradientBrush}" />
            <sdk:Label Height="17" Margin="8,8,0,0" Content="Search Options" Width="95" Style="{StaticResource ResourceKey=TitleLabel}" IsTabStop="False" />
            <Grid Margin="8,38,9,0" Height="511" VerticalAlignment="Top">
                <sdk:TreeView Height="242" Margin="0,8,0,0" VerticalAlignment="Top" Style="{StaticResource MainTreeViewStyle}" IsTabStop="False">
                    <sdk:TreeViewItem Header="SQL Server Instance" Style="{StaticResource ResourceKey=TreeViewItemStyle}" IsTabStop="False">
                        <ComboBox ItemsSource="{Binding SqlInstances}" SelectedItem="{Binding SelectedSqlInstance, Mode=TwoWay}" IsEnabled="{Binding IsSqlInstanceDropDownEnabled}" Width="169" Style="{StaticResource ResourceKey=ComboBoxStyle}" TabIndex="1" IsTabStop="True" />
                        <Button Content="Add Server Instance" Style="{StaticResource MainButtonStyle}" Command="{Binding InstanceCommand}" Width="169" Height="27" TabIndex="2" IsTabStop="True" />
                    </sdk:TreeViewItem>
                    <sdk:TreeViewItem Header="Databases" Style="{StaticResource ResourceKey=TreeViewItemStyle}" IsTabStop="False">
                        <ComboBox ItemsSource="{Binding Databases}" SelectedItem="{Binding SelectedDatabase, Mode=TwoWay}" IsEnabled="{Binding IsDatabasesDropDownEnabled}" Width="169" Style="{StaticResource ResourceKey=ComboBoxStyle}" IsTabStop="True" TabIndex="3" />
                    </sdk:TreeViewItem>
                    <sdk:TreeViewItem Header="FileTables" Style="{StaticResource ResourceKey=TreeViewItemStyle}" IsTabStop="False">
                        <ComboBox ItemsSource="{Binding FileTables}" SelectedItem="{Binding SelectedFileTable, Mode=TwoWay}" IsEnabled="{Binding IsFileTablesDropDownEnabled}" Width="169" Style="{StaticResource ResourceKey=ComboBoxStyle}" IsTabStop="True" TabIndex="4" />
                        <Button Content="Create File Table" Style="{StaticResource MainButtonStyle}" IsEnabled="{Binding IsSqlInstanceDropDownEnabled}" Command="{Binding FileTableCommand}" Width="169" Height="27" TabIndex="5" IsTabStop="True" />
                    </sdk:TreeViewItem>
                </sdk:TreeView>
                <sdk:TreeView Name="SearchTreeView" Margin="0,256,0,0" Height="247" VerticalAlignment="Top" Style="{StaticResource MainTreeViewStyle}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled" IsTabStop="False">
                    <sdk:TreeViewItem Header="Full text search" Style="{StaticResource ResourceKey=TreeViewItemStyle}" IsExpanded="True" IsTabStop="False">
                        <TextBox Name="SearchTextBox" Text="{Binding SearchText, Mode=TwoWay}" Style="{StaticResource SearchTextBoxTemplate}" Width="169" ToolTipService.ToolTip="Insert search text here" Height="24" TabIndex="6" IsTabStop="True" />
                    </sdk:TreeViewItem>
                    <sdk:TreeViewItem Style="{StaticResource ResourceKey=TreeViewItemStyle}" IsExpanded="True" Header="Filter by Tag" IsTabStop="False">
                    	<ComboBox SelectedItem="{Binding TagListSelectedItem, Mode=TwoWay}" ItemsSource="{Binding DatabaseTags}" Width="169" Style="{StaticResource ResourceKey=ComboBoxStyle}" IsTabStop="True" TabIndex="7" Name="TagFilterComboBox">
                    		<i:Interaction.Triggers>
                    			<i:EventTrigger EventName="DropDownClosed">
                    				<i:InvokeCommandAction Command="{Binding TagFilterSelectionChanged}" CommandParameter="{Binding ItemsSource, ElementName=TagFilterComboBox}"/>
                    			</i:EventTrigger>
                    		</i:Interaction.Triggers>
                    		<ComboBox.ItemTemplate>
                    			<DataTemplate>
                    				<StackPanel Orientation="Horizontal">
                    					<CheckBox ClickMode="Press" IsChecked="{Binding IsSelected, Mode=TwoWay}" Content="{Binding Name}" />
                    				</StackPanel>
                    			</DataTemplate>
                    		</ComboBox.ItemTemplate>
                    	</ComboBox>
                    </sdk:TreeViewItem>
                    <sdk:TreeViewItem Margin="0" Style="{StaticResource TreeViewItemStyle}" IsExpanded="True" Header="Filter Document Property" IsTabStop="False">
                    	<ComboBox Name="cmbSearchDocumentProperty" Width="169" ItemsSource="{Binding SearchDocumentProperties}" SelectedItem="{Binding SelectedSearchDocumentProperty, Mode=TwoWay}" IsEnabled="{Binding IsFiletablesDropDownEnabled}" Style="{StaticResource ResourceKey=ComboBoxStyle}" TabIndex="8" IsTabStop="True" />
                        <TextBox Name="txtBoxSearchDocumentProperty" Width="169" Margin="0,0,0,0" ToolTipService.ToolTip="Filter documents by name." Text="{Binding TxtSearch, Mode=TwoWay}" IsEnabled="{Binding IsFiletablesDropDownEnabled}" Style="{StaticResource SearchTextBoxTemplate}" Visibility="{Binding SelectedSearchDocumentProperty.UseString}" IsTabStop="True" TabIndex="9" />
                    </sdk:TreeViewItem>
                </sdk:TreeView>
            </Grid>
            <Grid Height="27" Margin="8,501,9,0" VerticalAlignment="Top">
                <Button Name="SearchButton" Command="{Binding UpdateDocumentsCommand}" Content="Search" Style="{StaticResource MainButtonStyle}" Margin="46,0,13,0" Background="#FF1F3B53" BorderThickness="1" Width="169" Height="27" IsTabStop="True" TabIndex="10" />
                <Image Source="Images/update.png" Width="16" Margin="75,4,0,6" RenderTransformOrigin="0.625,1.294" Style="{StaticResource ResourceKey=ImageStyle}" />
            </Grid>
        </Grid>
        <Grid Height="35" Margin="798,69,12,0" VerticalAlignment="Top">
            <sdk:Label Width="400" Margin="0,-1,0,18" Style="{StaticResource ResourceKey=StatusLabel}" Content="{Binding TagAmountStatus, StringFormat=Showing \{0\} tags}" IsTabStop="False" />
            <sdk:Label Width="400" Margin="0,16,0,1" Style="{StaticResource ResourceKey=StatusLabel}" Content="{Binding TagTargetStatus, StringFormat=Tags for: \{0\}}" IsTabStop="False" />
        </Grid>
    </Grid>
</UserControl>
